import {
    api
} from '@/common/utils/request.js';
import {
    toPageParam,
    toPageResult
} from '@/common/services/index.js'

const baseUrl = "https://it.hiportal.cn/it_api";
//公共参数
const requestData = (url, data) => {
    return {
        //不需要登录信息
        auth: false,
        //成功code值
        successCode: 200,
        //指定接口地址
        host: baseUrl,
        //接口
        url: url,
        data: data || {}
    };
}

/*屏3 房间信息概要 */
export function getHouseInfoStatistics() {
    return api(requestData("/lock/lockBv/getHouseInfoStatistics"));
    /*
     返回结果：
     {
       "msg": "操作成功",
       "code": 200,
       "data": {
         "rentRoomAmount": 1,         //在住房间
         "checkInAmount": 3,          //在住人数
         "historyCheckInAmount": 3,    //历史在住人数
          "regHouseOwnerAmount": 4,   //已登记房东
         "checkInRate": "100%",        //入住率
         "installLocksAmount": 1         //安装锁房间
       }}
     */
}

/*屏3 房东及房屋信息列表 */
export function getHouseOwnerInfo(data) {
    /*
    data={
        detailAddr string 地址详细
        houseOwnerLicence  string  房东证件号
        houseOwnerMoble  string  房东手机号
        houseOwnerName string  房东名称
    }
     */
    return api(requestData("/lock/lockBv/getHouseOwnerInfo", data));
    /*
     返回结果：
     {
       "msg": "操作成功",
       "code": 200,
       "data": [
         {
           "houseOwnerName": "王伟",  //姓名
           "houseOwnerLicence": null,  //证件号
           "houseOwnerMoble": "18902810298",  //手机号
           "detailAddr": "杭州市拱墅区湖墅街道和睦新村1幢2单元303",  //地址
           "roomAmount": 1,  //房间数量
           "roomList": [
             {
               "lockId": "31333384701106589696",//锁ID
               "checkInAmount": 1,   //入住人数
               "roomNo": "1551",    //房号
               "roomId": "22337340070040309760"         }
           ]
         }
       ]}
     */
}

/*屏3 房间对应的租客列表 */
export function getRoomCheckInInfoList(data) {
    /*
    data={
        roomId  string 房间ID
    }
     */
    return api(requestData("/lock/lockBv/getRoomCheckInInfoList", data));

    /*
    返回
    {
      "msg": "操作成功",
      "code": 200,
      "data": [
        {
          "lockId": "31333384701106589696",
          "realName": "李振华",
          "expireTime": 1671811200000, //租房结束时间
          "bleName": "MVL065F",
          "phonenumber": "13675864178",
          "startTime": 1666540800000, //租房开始时间
          "installTime": 1665129375000, //门锁安装时间
          "srrzState": 3, //实名认证状态 0-2 未认证  3-4 已经认证
          "zjhm": "330782198809040408"  //证件号
        }
      ]}

     */
}


/*屏2 房间信息 */
export function getLockHouseInfo() {
    return api(requestData("/lock/lockBv/getLockHouseInfo"));
    /*
     {
         "msg": "操作成功",
         "code": 200,
         "data": {
             "installLockRoomAmount": 0,  //安装房间数量
             "regRoomAmount": 1,    //登记的房间数
             "lockInstallRate": "0.0",  //安装率
             "houseProprietor1": 0, //政府保障性租房
             "houseProprietor2": 0, //政府保障性租房
             "houseProprietor3": 0, //村（社区）自建公寓
             "houseProprietor4": 0,//企业宿舍
             "checkInAmountInRoom": [0, 1, 0]  //房屋出租情况  [未出租，单人，多人]
         }
     }



     */
}


/*屏2 钥匙信息 */
export function getLockInfo() {
    return api(requestData("/lock/lockBv/getLockInfo"));
    /*
     返回
     {
         "msg": "操作成功",
         "code": 200,
         "data": {
             "keysAmount": 4,  //在用钥匙
             "installLocks": 1, //安装锁
             "toDayInstallLocks": 0,  //今天安装锁
             "lockUseRate": "200",  //锁使用率
             "todayOpenAmount": 0, //今天开门
             "lastOpenTime": "2022-10-24 17:52", //最近开门时间
             "todaySendKeys": 0, //今天发送钥匙
             "smrzList": [1, 2], //  认证数量  [未认证，已认证]
             "keyTypeList": [3, 0, 0] 钥匙类型[电子钥匙，密码，IC卡]
         }
     }
     */
}


/* 屏2 在住人员信息 */
export function getCheckInInfo() {
    return api(requestData("/lock/lockBv/getCheckInInfo"));
    /*
     返回
     {
         "msg": "操作成功",
         "code": 200,
         "data": {
             "checkInAmount": 3,
             "historyCheckInAmount": 3,
             "todayCheckInAmount": 0,
             "todayCheckOutAmount": 0,
             "todayRoomChange": 0,
             "phoneAmount": 59,
             "oneMorePhoneAmount": 0,
             "maximumPhoneAmount": 1
         }
     }
     */
}


/* 屏1 基础接口 */
export function index01() {
    return api(requestData("/lock/lockBv/index01"));
    /*
     返回
     {
         "msg": "操作成功",
         "code": 200,
         "data": {
             "regRoomAmount": 7,   //登记房间
             "installLockRoomAmount": 2, //已经安装锁房间
             "unInstallLockRoomAmount": 5,  //未安装锁房间
             "unCheckInRoomAmount": 6, //空置房屋数
             "checkInRoomAmount": 1, //在住房屋数
             "checkInAmount": 1, //在住人数
             "checkOutToDay": 1, // 今日离开
             "checkInToDay": 2, //今日入住
             "longUnRentRoom": [1, 1, 1],  长期未出租情况[15-30天,31-45天,45天以上]
             "longUnOpenLock": [1, 1, 1], 长期未使用钥匙情况[电子 ,  密码   ,  IC房卡]
             "checkInSexRate": [1, 1], 男女比例 [男,女]
             "checkInAgeRate": [1, 1, 1, 1, 1, 1, 1] 年龄分别[18周岁以下,18-30周岁,31-40周岁,41-50周岁,51-60周岁,61-70周岁,70周岁以上]

         }
     }

     */
}


/* 屏1 近期入住率趋势 */
export function getcheckInRateOption() {
    return api(requestData("/lock/lockBv/getcheckInRateOption"));
    /*
     返回
     {
         "msg": "操作成功",
         "code": 200,
         "data": {
             "nameList": ["10-20", "10-21", "10-22", "10-23", "10-24", "10-25"], 【日期】
             "valueList": [
                 ["0", "0", "0", "0", "0", "0"] 【入住率】
             ]
         }
     }

     */
}


/* 屏1  近期新入住与离开 */
export function getCheckInOutOption() {
    return api(requestData("/lock/lockBv/getCheckInOutOption"));
    /*
     返回
    {
        "msg": "操作成功",
        "code": 200,
        "data": {
            "nameList": ["10-20", "10-21", "10-22", "10-23", "10-24", "10-25"],  【日期】
            "valueList": [
                ["0", "0", "0", "0", "0", "0"],   【入住】
                ["0", "0", "0", "0", "0", "0"]    【离开】
            ]
        }
    }
     */
}

/* 屏1  近期开门行为情况 */
export function getOpenDoorOption() {
    return api(requestData("/lock/lockBv/getOpenDoorOption"));
    /*
     返回
    {
        "msg": "操作成功",
        "code": 200,
        "data": {
            "nameList": ["10-20", "10-21", "10-22", "10-23", "10-24", "10-25"],【日期】
            "valueList": [
                ["0", "0", "0", "0", "0", "0"],  【电子钥匙】
                ["0", "0", "0", "0", "0", "0"],  【密码】
                ["0", "0", "0", "0", "0", "0"]   【IC卡】
            ]
        }
    }
     */
}


/* 屏1 籍贯分布 */
export function getBirthProvinceList() {
    return api(requestData("/lock/lockBv/getBirthProvinceList"));
    /*
     {
         "msg": "操作成功",
         "code": 200,
         "data": [
             {
                 "province": "湖北省",
                 "n": 1
             }
            ]
     }

     */
}
